import request from '@/utils/requestH2'

/* 系统配置 */

/* 部门管理 */

// 部门列表查询
export function selDepartmentListApi(params) {
  return request({
    url: '/system/department/selDepartmentList',
    method: 'GET',
    params
  })
}

// 新增部门
export function addDepartmentApi(data) {
  return request({
    url: '/system/dep/addDepartment',
    method: 'POST',
    data
  })
}

// 编辑部门
export function updateDepartmentByIdApi(data) {
  return request({
    url: `/system/dep/updateDepartmentById/${data.id}`,
    method: 'PUT',
    data: {
      name: data.name,
      parentId: data.parentId
    }
  })
}

// 根据ids删除部门
export function delDepartmentByIdsApi(data) {
  return request({
    url: '/system/dep/delDepartmentByIds',
    method: 'DELETE',
    data
  })
}

// 根据id查询部门详情
export function selDepartmentByIdApi(id) {
  return request({
    url: `/system/dep/selDepartmentById/${id}`,
    method: 'GET'
  })
}

/* 功能管理 */

// 功能列表查询
export function selFunctionListApi(params) {
  return request({
    url: '/system/function/selFunctionList',
    method: 'GET',
    params
  })
}

// 新增功能
export function addFunctionApi(data) {
  return request({
    url: '/system/function/addFunction',
    method: 'POST',
    data
  })
}

// 编辑功能
export function updateFunctionByIdApi(params) {
  return request({
    url: `/system/function/updateFunctionById/${params.id}`,
    method: 'PUT',
    params: {
      id: params.id,
      name: params.name,
      number: params.number,
      sign: params.sign
    }
  })
}

// 根据ids删除功能
export function delFunctionByIdApi(data) {
  return request({
    url: '/system/function/delFunctionById',
    method: 'DELETE',
    data
  })
}

// 根据id查询功能详情
export function selFunctionByIdApi(id) {
  return request({
    url: `/system/function/selFunctionById/${id}`,
    method: 'GET'
  })
}

/* 角色管理 */

// 角色列表查询
export function selRoleListApi(params) {
  return request({
    url: '/system/role/selRoleList',
    method: 'GET',
    params
  })
}

// 新增角色
export function addRoleApi(data) {
  return request({
    url: '/system/role/addRole',
    method: 'POST',
    data
  })
}

// 编辑角色
export function updateRoleByIdApi(params) {
  return request({
    url: `/system/role/updateRoleById/${params.id}`,
    method: 'PUT',
    params: {
      name: params.name,
      isDelete: params.isDelete,
      number: params.number,
      remark: params.remark
    }
  })
}

// 根据ids删除角色
export function delRoleByIdApi(data) {
  return request({
    url: '/system/role/delRoleById',
    method: 'DELETE',
    data
  })
}

// 根据id查询角色详情
export function selRoleByIdApi(id) {
  return request({
    url: `/system/role/selRoleById/${id}`,
    method: 'GET'
  })
}

// 最新角色编号查询
export function selNewRoleNumberApi() {
  return request({
    url: '/system/role/selNewRoleNumber',
    method: 'GET'
  })
}

/* 用户管理 */

// 用户列表查询
export function selUserListApi(params) {
  return request({
    url: '/system/user/selUserList',
    method: 'GET',
    params
  })
}

// 新增用户
export function addUserApi(data) {
  return request({
    url: '/system/user/addUser',
    method: 'POST',
    data
  })
}

// 编辑用户
export function updateUserByIdApi(data) {
  return request({
    url: `/system/user/updateUserById/${data.id}`,
    method: 'PUT',
    data: {
      department: data.department,
      email: data.email,
      loginName: data.loginName,
      mobile: data.mobile,
      name: data.name,
      password: data.password,
      roleId: data.roleId
    }
  })
}

// 根据ids删除用户
export function delUserByIdApi(data) {
  return request({
    url: '/system/user/delUserByIds',
    method: 'DELETE',
    data
  })
}

// 根据id查询用户详情
export function selUserByIdApi(id) {
  return request({
    url: `/system/user/selUserById/${id}`,
    method: 'GET'
  })
}

/* 菜单功能 */

// 菜单功能列表查询
export function selMenuListApi() {
  return request({
    url: '/system/menu/selMenuList',
    method: 'GET'
  })
}

// 新增菜单功能页面
export function addMenuApi(data) {
  return request({
    url: '/system/menu/addMenu',
    method: 'POST',
    data
  })
}

// 根据id编辑菜单
export function updateMenuByIdApi(data) {
  return request({
    url: `/system/menu/updateMenuById/${data.id}`,
    method: 'PUT',
    data: {
      isClose: data.isClose,
      isShow: data.isShow,
      name: data.name,
      url: data.url
    }
  })
}

// 根据id查询菜单功能列表
export function selMenuByIdApi(params) {
  return request({
    url: '/system/menu/selMenuById',
    method: 'GET',
    params
  })
}

// 根据ids删除菜单
export function delMenuByIdsApi(data) {
  return request({
    url: '/system/menu/delMenuByIds',
    method: 'DELETE',
    data
  })
}

/* 角色功能 */

// 根据id新增角色显示菜单
export function addRoleMenuApi(data) {
  return request({
    url: '/system/roleMenu/addRoleMenu',
    method: 'POST',
    data
  })
}

// 根据id删除角色显示菜单
export function delRoleMenuByIdApi(data) {
  return request({
    url: `/system/roleMenu/delRoleMenuById/${data.roleId}/${data.menuId}`,
    method: 'DELETE'
  })
}

// 角色功能页面根据角色id查询菜单列表
export function selRoleMenuListByRoleIdApi(roleId) {
  return request({
    url: '/system/roleMenu/selRoleMenuListByRoleId',
    method: 'GET',
    params: {
      roleId
    }
  })
}
